/*
 * @file    FreeRTOSConfig.h
 * @author  Frederic Pillon <frederic.pillon@st.com> for STMicroelectronics.
 * @brief   Include header file to match Arduino library format
 */

#ifndef _ARDUINO_FREERTOS_CONFIG_H
#define _ARDUINO_FREERTOS_CONFIG_H

/* Application specific configuration options. */
#if __has_include("STM32FreeRTOSConfig.h")
#include "STM32FreeRTOSConfig.h"
#else
#if __has_include("STM32FreeRTOSConfig_extra.h")
#include "STM32FreeRTOSConfig_extra.h"
#endif
#include "FreeRTOSConfig_Default.h"
#endif
#ifdef TRC_USE_TRACEALYZER_RECORDER
#include "trcRecorder.h"
#define INCLUDE_xTaskGetCurrentTaskHandle				1	// 启用一个可选函数（该函数被 Trace源码使用，默认该值为0 表示不用）
#endif
#ifdef TRACESNIFFER
#include <sniffImport.h>
#endif
#ifdef USE_SEGGER_SYSVIEW
#include "SEGGER_SYSVIEW_FreeRTOS.h"
#endif
#define INCLUDE_xTaskGetIdleTaskHandle    1
#define INCLUDE_pxTaskGetStackStart        1
#if (configUSE_TICKLESS_IDLE == 2)

//      Preprocessor code in lptimTick.c requires that configTICK_RATE_HZ be a preprocessor-friendly numeric
// literal.  As a result, the application *ignores* the CubeMX configuration of the FreeRTOS tick rate.
//
#undef  configTICK_RATE_HZ
#define configTICK_RATE_HZ  1000UL  // <-- Set FreeRTOS tick rate here, not in CubeMX.

//      Don't bother installing xPortSysTickHandler() into the vector table or including it in the firmware
// image at all.  FreeRTOS doesn't use the SysTick timer nor xPortSysTickHandler() when lptimTick.c is
// providing the OS tick.
//
#undef  xPortSysTickHandler

#endif // configUSE_TICKLESS_IDLE == 2
//
// Integrate lptimTick.c -- End of Block

#if (configUSE_TICKLESS_IDLE == 2)

//      Without pre- and post-sleep processing, lptimTick.c uses only basic sleep mode during tickless idle.
// To utilize the stop modes and their dramatic reduction in power consumption, we employ an ultra-low-power
// driver to handle the pre- and post-sleep hooks.
//
#define configPRE_SLEEP_PROCESSING(x)   vUlpPreSleepProcessing()
#define configPOST_SLEEP_PROCESSING(x)  vUlpPostSleepProcessing()

//      Make sure the self-tests in our demo application capture tick-timing information as quickly as
// possible after each tick.  This interrupt priority ensures the OS tick ISR preempts other ISRs.  Without
// this configuration, interrupt latency causes a little extra jitter during the stress test.  See main.c.
// To see the effect of interrupt latency in the terminal output, remove or comment out this line.
//
// #define configTICK_INTERRUPT_PRIORITY   (configLIBRARY_LOWEST_INTERRUPT_PRIORITY - 1)

//      The Nucleo board gives us Vdd=3.3V, so we need only 2us minimum run time to work around erratum
// 2.3.21.  Note that when we define this symbol, code in ulp.c owns the SysTick timer.  At the moment, our
// demo application doesn't have any relevant ISRs short enough to violate this minimum run time, so we
// don't enable the work around.  (The shortest possible run time between deep sleeps occurs with a very
// short ISR that interrupts STOP mode but doesn't interact with FreeRTOS at all.  See lptimTick.c.)
//
// #define configMIN_RUN_BETWEEN_DEEP_SLEEPS  ( ( 2U * configCPU_CLOCK_HZ ) / 1000000 )

#endif // configUSE_TICKLESS_IDLE == 2

#endif /* _ARDUINO_FREERTOS_CONFIG_H */

